package com.analysis.common;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

public class ConfigUtil {
    private static Config config = ConfigFactory.load();
    public static final String parameter = "%%%%";

    public static Config getConfig() {
        return config;
    }

    public static String getString(String path) {
        return config.getString(path);
    }

    public static String getString(String key, String... fill) {
        String url = getString(key);
        if (url != null && url.contains(parameter)) {
            String[] splitURL = url.split(parameter);
            url = "";
            for (int i = 0; i < splitURL.length; i++) {
                if (i < fill.length) {
                    url += splitURL[i] + fill[i];
                } else {
                    url += splitURL[i];
                }
            }
        }
        return url;
    }

    public static Config getConfig(String path) {
        return config.getConfig(path);
    }


    public static void main(String[] args) {
        System.out.println(ConfigUtil.getString("kline.fromWeb"));
    }
}
